package com.sgai.dcac.presenter;

import com.sgai.dcac.contract.LoginContract;
import com.sgai.dcac.ui.view.LoginView;
import com.sgai.dcac.utils.SharedPreferencesUtil;

/**
 * Created by tony on 2017/6/14.
 */

public class TestLoginPresenter implements LoginContract.Presenter {

    private LoginView login;

    public TestLoginPresenter(LoginView login) {
        this.login = login;
    }

    @Override
    public void doLogin(String username, String password) {
        if (username.equals("hxf")&&password.equals("123")) {
            login.success("success");
            //设置登录成功状态 token 用户信息
            SharedPreferencesUtil.setLoginState(true);
            SharedPreferencesUtil.setToken("token");
            SharedPreferencesUtil.setUserId("1");
            SharedPreferencesUtil.setUsername("hxf");
        } else {
            login.failure("falure");
        }

    }

    @Override
    public void success(String str) {

    }

    @Override
    public void failure(String str) {

    }
}
